import _set from "lodash/set";
import _forEach from "lodash/forEach";

/**
 * 仅对 Toolbar 按钮的onClick 做特殊处理
 */
import { Button } from 'antd';
import { dealObjectProps } from "../utils";
var types = {
  Button: Button
};
export function dealToolbarProps(toolbarProps, context) {
  return dealObjectProps(toolbarProps, context);
}
export function dealButtonProps(_ref) {
  var field = _ref.field,
      context = _ref.context;
  var otherProps = {};

  _forEach(field.props, function (propV, propK) {
    _set(otherProps, propK, propV);
  });

  var btn = otherProps.btn;
  delete otherProps.btn;
  var dealProps = dealObjectProps(otherProps, context);
  return {
    componentProps: dealProps,
    btn: btn
  };
}
/**
 * getBtnType - 获取字段的组件类型
 * @param {Object} field - 字段
 */

export function getBtnType(_ref2) {
  var field = _ref2.field;
  return types[field.componentType] || types.Button;
}